package com.isoftstone.studentregistration.util;
/**
 * 统一返回结果类
 */
import lombok.Data;

import java.io.Serializable;
@Data
public class Result<T> implements Serializable {
    //序列化版本号
    private static final long serialVersionUID = 1L;
    //状态码,200为成功,非200为异常
    private Integer code;
    //返回信息
    private String message;
    //返回数据
    private T data;
    public Result() {
    }//构造方法无参构造方法
    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }//构造方法2个参数参构造方法
    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }//构造方法3个参数参构造方法
    public static <T> Result<T> success() {
        return new Result<T>(200, "操作成功");
    }

    public static <T> Result<T> success(T data) {
        return new Result<T>(200, "操作成功", data);
    }
    public static <T> Result<T> success(String message,T data) {
        return new Result<T>(200, message,data);
    }

    public static <T> Result<T> error(Integer code, String message) {
        return new Result<T>(code, message);
    }
    public static <T> Result<T> error(String message) {
        return new Result<T>(500, message);
    }



}
